/**
 * base    : 基础业务API
 * buyer   : 买家API
 */
import devEnv from './env.dev.js'
import prodEnv from './env.prod.js'

const getServer = (type, enviroment) => {
	// 默认是测试环境
  let server = devEnv.apiUrl
  if (enviroment === 'prod') {
    server = prodEnv.apiUrl
  }
  let serverUrl = `${server}/api/${type}`
  return serverUrl
}
// 测试环境
const dev = {
  im: getServer('im'),
  common: getServer('common'),
  buyer: getServer('buyer'),
  baseWsUrl: devEnv.baseWsUrl
};
// 生产环境
const prod = {
  im: getServer('im', 'prod'),
  common: getServer('common', 'prod'),
  buyer: getServer('buyer', 'prod'),
  baseWsUrl: prodEnv.baseWsUrl
};

//默认测试环境
let api = dev;
//如果是测试环境
if (process.env.NODE_ENV == "development") {
  api = dev;
} else {
  api = prod;
}
//微信小程序，app的打包方式建议为生产环境，所以这块直接条件编译赋值
// #ifdef MP-WEIXIN || APP-PLUS
api = dev;
// #endif

api.buyer += "/buyer";
api.common += "/common";
api.im += "/im";
export default {
  ...api,
};